
package com.joysuch.wwyt.common.enums;

/**
 * 生产装置状态
 *
 */
public enum CoursewareStates {

    INITIAL(0, "待申请"), WAITING_FOR_AUDIT(1, "待审核"), AUDIT_SUCCESS(2, "审核通过"), AUDIT_FAILED(3, "审核失败");

    private byte id;
    private String name;

    private CoursewareStates(int id, String name) {
        this.id = (byte) id;
        this.name = name;
    }

    public byte getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public static CoursewareStates findByName(String name) {
        CoursewareStates[] values = CoursewareStates.values();
        for (CoursewareStates v : values) {
            if (v.getName().equals(name)) {
                return v;
            }
        }
        return null;
    }

    public static CoursewareStates findById(Integer level) {
        CoursewareStates[] values = CoursewareStates.values();
        for (CoursewareStates v : values) {
            if (v.getId() == level) {
                return v;
            }
        }
        return null;
    }

    public static String findNameById(Byte id) {
        if (id == null) {
            return null;
        }
        CoursewareStates[] values = CoursewareStates.values();
        for (CoursewareStates v : values) {
            if (v.getId() == id) {
                return v.getName();
            }
        }
        return null;
    }
}
